package com.blank.web.servlet;

import com.blank.web.bean.Student;
import com.blank.web.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "afterUpdateServlet",urlPatterns = "/afterUpdate")
public class afterUpdateServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        int sid =Integer.parseInt(request.getParameter("sid"));
        String sName = request.getParameter("sName");
        String gender = request.getParameter("gender");
        String sdate = request.getParameter("sdate");
        String email = request.getParameter("email");
        String remark = request.getParameter("remark");
        int classId = Integer.parseInt(request.getParameter("classId"));
        Student student = new Student();
        student.setSid(sid);
        student.setsName(sName);
        student.setGender(gender);
        student.setSdate(sdate);
        student.setEmail(email);
        student.setRemark(remark);
        student.setClassId(classId);

        StudentService studentService = new StudentService();
        studentService.Update(student);
        System.out.println(student);
        request.getRequestDispatcher("showStuInfo").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
